import collection.list.Person;

import java.io.*;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
//        SuperClass sc1 = new SubClass1();
//        SuperClass sc2 = new SubClass2();
//        sc1.name = "Mr.Jack";
//        sc2.name = "Miss.Jack";
//        sc1.show();
//        sc2.show();
//        Processor filterAdapter = new FilterAdapter();
//        filterAdapter.process("hello");


//        Person[] persons = new Person[3];
//        persons[0] = new Person("zhangsan");
//        persons[1] = new Person("lisi");
//        persons[2] = new Person("join");
//        System.out.println(Arrays.toString(persons));

        //序列化对象
//        Employee e = new Employee();
//        e.name = "Ryan";
//        e.address = "cilong street";
//        e.SSN = 111233325;
//        e.number = 101;
//        try {
//            FileOutputStream fileOutputStream = new FileOutputStream("tmp\\employee.ser");
//            ObjectOutputStream out = new ObjectOutputStream(fileOutputStream);
//            out.writeObject(e);
//            out.close();
//            fileOutputStream.close();
//            System.out.println("Serialized data is saved in /tmp/employee.ser");
//        } catch (IOException i) {
//            i.printStackTrace();
//        }

        //反序列化对象
        Employee e = null;
        try {
            FileInputStream fileInputStream = new FileInputStream("tmp\\employee.ser");
            ObjectInputStream in = new ObjectInputStream(fileInputStream);
            e = (Employee) in.readObject();
            in.close();
            fileInputStream.close();
        } catch (IOException i) {
            i.printStackTrace();
            return;
        } catch (ClassNotFoundException c) {
            System.out.println("Employee class not found");
            c.printStackTrace();
            return;
        }
        System.out.println("Deserialized Employee...");
        System.out.println("Name: " + e.name);
        System.out.println("Address: " + e.address);
        System.out.println("SSN: " + e. SSN);
        System.out.println("Number: " + e.number);
    }
}
